package Watcher.impl;

import Watcher.IFavorites;
import Watcher.IVideo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public final class Favorites implements Serializable, IFavorites {
	private List<Favorite> favoriteList;
	private IVideo video;

	public Favorites(final IVideo video) {
		this.video = video;
		favoriteList = new ArrayList<Favorite>();
	}

	public Favorites(final Favorites favorites) {
		favoriteList = favorites.favoriteList;
	}

	/* (non-Javadoc)
	 * @see Watcher.IFavorites#add(Watcher.impl.Favorite)
	 */
	public void add(final Favorite favorite) {
		favoriteList.add(favorite);
	}

	/* (non-Javadoc)
	 * @see Watcher.IFavorites#removeAt(int)
	 */
	public void removeAt(final int position) {
		favoriteList.remove(position);
	}

	/* (non-Javadoc)
	 * @see Watcher.IFavorites#getFrom(int)
	 */
	public Favorite getFrom(final int position) {
		return favoriteList.get(position);
	}

	/* (non-Javadoc)
	 * @see Watcher.IFavorites#getQuantity()
	 */
	public int getQuantity() {
		return favoriteList.size();
	}

	/* (non-Javadoc)
	 * @see Watcher.IFavorites#asList()
	 */
	public List<Favorite> asList() {
		return favoriteList;
	}

	/* (non-Javadoc)
	 * @see Watcher.IFavorites#play(int)
	 */
	public void play(final int position) {
		this.video.play(favoriteList.get(position).getLink());
	}
}
